#ifndef __SYS_H
#define __SYS_H

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>

#define APP_CNT_MAX 10   //最多10个app监控数量
#define MAX_NAME_LEN 50
#define MAX_TOPIC_LEN 100
#define MAX_CMD_LEN 100
#define MAX_PATH_LEN 100

typedef struct  {
    char name[MAX_NAME_LEN];    //app 名称
    int  old_stat;
    int  new_stat;              //-1:异常 0:none 1:正常
    bool bUpd;                  //false:未升级 true:升级中
    int  err_cnt;
    int  rest_cnt;
    bool app_recv;              //查询app状态一次，是否接收到标志
} app_items;

typedef struct  {
    // char bat_val[5];
    app_items app[APP_CNT_MAX];
} sys_status_t;

typedef struct {
    char app[50];
    char file[100];
    char cmd[50];
} files_info_t;

typedef struct {
    char ver[10];
    char sn[20];
    int app_cnt;
    files_info_t app_list[APP_CNT_MAX];
} app_launch_list_t;

struct fy_document *fyd;
struct fy_node *fyn, *fyn_ver, *fyn_cmd, *fyn_root, *fyn_rootpath, *fyn_url, *fyn_sys, *fyn_app, *fyn_files, *fyn_file, *fyn_md5;

int is_dir_exist(const char *dir_path);
int app_launch_list_write(char* buf);
int app_launch_list_write_1(char *path, char* buf);
int sys_mangers_check(void);
int sys_init(char* path);
#endif
